PolymorphicValidator<T, TProperty>
Performs runtime checking of the value being validated, and passes validation off to a subclass validator.
Assembly: ServiceStack.dll
View Source
public class PolymorphicValidator<T, TProperty> : ChildValidatorAdaptor<T, TProperty>, IPropertyValidator, IChildValidatorAdaptor
Methods
Add<TDerived>(IValidator<TDerived>, String[])
Adds a validator to handle a specific subclass.
View Source
public PolymorphicValidator<T, TProperty> Add<TDerived>(IValidator<TDerived> derivedValidator, params string[] ruleSets)
where TDerived : TProperty
Returns
[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty
)
Parameters
Type | Name | Description |
---|---|---|
ServiceStack.FluentValidation.IValidator<T> | derivedValidator | The derived validator |
|
| System.String[]
| ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run
|
Type Parameters
TDerived
Add<TDerived>(Func<T, IValidator<TDerived>>, String[])
Adds a validator to handle a specific subclass.
View Source
public PolymorphicValidator<T, TProperty> Add<TDerived>(Func<T, IValidator<TDerived>> validatorFactory, params string[] ruleSets)
where TDerived : TProperty
Returns
[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty
)
Parameters
Type | Name | Description |
---|---|---|
System.Func<<T>,ServiceStack.FluentValidation.IValidator<<TDerived>>> | validatorFactory | The derived validator |
|
| System.String[]
| ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run
|
Type Parameters
TDerived
Add<TDerived>(Func<T, TDerived, IValidator<TDerived>>, String[])
Adds a validator to handle a specific subclass.
View Source
public PolymorphicValidator<T, TProperty> Add<TDerived>(Func<T, TDerived, IValidator<TDerived>> validatorFactory, params string[] ruleSets)
where TDerived : TProperty
Returns
[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty
)
Parameters
Type | Name | Description |
---|---|---|
System.Func<<T>,<TDerived>,ServiceStack.FluentValidation.IValidator<<TDerived>>> | validatorFactory | The derived validator |
|
| System.String[]
| ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run
|
Type Parameters
TDerived
Add(Type, IValidator, String[])
Adds a validator to handle a specific subclass. This method is not publicly exposed as it takes a non-generic IValidator instance which could result in a type-unsafe validation operation. It allows derived validaors more flexibility in handling type conversion. If you make use of this method, you should ensure that the validator can correctly handle the type being validated.
View Source
protected PolymorphicValidator<T, TProperty> Add(Type subclassType, IValidator validator, params string[] ruleSets)
Returns
[ServiceStack.FluentValidation.Validators.PolymorphicValidator<T, TProperty>](../ServiceStack.FluentValidation.Validators/PolymorphicValidatorT, TProperty
)
Parameters
Type | Name | Description |
---|---|---|
System.Type | subclassType |
| | ServiceStack.FluentValidation.IValidator | validator |
|
| System.String[]
| ruleSets | Optionally specify rulesets to execute. If set, rules not in these rulesets will not be run
|
GetValidator(PropertyValidatorContext)
View Source
public override IValidator<TProperty> GetValidator(PropertyValidatorContext context)
Returns
ServiceStack.FluentValidation.IValidator<T>
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.Validators.PropertyValidatorContext | context |
CreateNewValidationContextForChildValidator(PropertyValidatorContext, IValidator<TProperty>)
View Source
protected override IValidationContext CreateNewValidationContextForChildValidator(PropertyValidatorContext context, IValidator<TProperty> validator)
Returns
ServiceStack.FluentValidation.IValidationContext
Parameters
Type | Name |
---|---|
ServiceStack.FluentValidation.Validators.PropertyValidatorContext | context |
ServiceStack.FluentValidation.IValidator<T> | validator |